///////////////////////////////////////////////////////////////////////////////
//
// Licensed under the MIT License
//
// Copyright (c) 2010 Chris Colinsky
// All Rights Reserved
//
// version	0.5
// http://code.google.com/p/sugarcookie/
// http://code.google.com/p/sugarcookie/wiki/License
//
////////////////////////////////////////////////////////////////////////////////

package sugarcookie.validators {
	/**
	 * Validates email addresses.
	 */
	public class EmailValidator {
		private static const EMAIL_REGEX : RegExp = /^[a-zA-Z0-9][\w.-]+@\w[\w.-]+\.[\w.-]*[a-zA-Z0-9][a-zA-Z0-9]$/i;
		
		public static function validate(str:String):ValidationResult {
			if (EMAIL_REGEX.test(str)) return new ValidationResult("Email is valid",true);
			else return new ValidationResult("Email is not a valid format",false);
		}
	}
}